package com.talos.ums.dal.mysql.resource;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.resource.vo.UmsResourcePageReqVO;
import com.talos.ums.dal.dataobject.resource.UmsResourceDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 资源表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsResourceMapper extends BaseMapperX<UmsResourceDO> {

    default PageResult<UmsResourceDO> selectPage(UmsResourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsResourceDO>()
                .eqIfPresent(UmsResourceDO::getAppId, reqVO.getAppId())
                .eqIfPresent(UmsResourceDO::getCode, reqVO.getCode())
                .likeIfPresent(UmsResourceDO::getName, reqVO.getName())
                .eqIfPresent(UmsResourceDO::getParentResourceId, reqVO.getParentResourceId())
                .eqIfPresent(UmsResourceDO::getParentResourceCode, reqVO.getParentResourceCode())
                .eqIfPresent(UmsResourceDO::getTerminal, reqVO.getTerminal())
                .likeIfPresent(UmsResourceDO::getServiceName, reqVO.getServiceName())
                .eqIfPresent(UmsResourceDO::getSystem, reqVO.getSystem())
                .eqIfPresent(UmsResourceDO::getSystemType, reqVO.getSystemType())
                .eqIfPresent(UmsResourceDO::getResourceTypeCode, reqVO.getResourceTypeCode())
                .eqIfPresent(UmsResourceDO::getResourceTypeMessage, reqVO.getResourceTypeMessage())
                .eqIfPresent(UmsResourceDO::getResourceUrl, reqVO.getResourceUrl())
                .eqIfPresent(UmsResourceDO::getResourceCss, reqVO.getResourceCss())
                .eqIfPresent(UmsResourceDO::getResourceSort, reqVO.getResourceSort())
                .eqIfPresent(UmsResourceDO::getResourceLevel, reqVO.getResourceLevel())
                .eqIfPresent(UmsResourceDO::getCustomFlag, reqVO.getCustomFlag())
                .eqIfPresent(UmsResourceDO::getActiveFlag, reqVO.getActiveFlag())
                .eqIfPresent(UmsResourceDO::getLang, reqVO.getLang())
                .eqIfPresent(UmsResourceDO::getCreatorId, reqVO.getCreatorId())
                .betweenIfPresent(UmsResourceDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsResourceDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsResourceDO::getCreatorName, reqVO.getCreatorName())
                .eqIfPresent(UmsResourceDO::getModifierId, reqVO.getModifierId())
                .betweenIfPresent(UmsResourceDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsResourceDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsResourceDO::getModifierName, reqVO.getModifierName())
                .eqIfPresent(UmsResourceDO::getPath, reqVO.getPath())
                .eqIfPresent(UmsResourceDO::getIsShow, reqVO.getIsShow())
                .eqIfPresent(UmsResourceDO::getIcon, reqVO.getIcon())
                .eqIfPresent(UmsResourceDO::getResourceIdTree, reqVO.getResourceIdTree())
                .eqIfPresent(UmsResourceDO::getResourceCodeTree, reqVO.getResourceCodeTree())
                .eqIfPresent(UmsResourceDO::getApis, reqVO.getApis())
                .eqIfPresent(UmsResourceDO::getButtonPermissions, reqVO.getButtonPermissions())
                .eqIfPresent(UmsResourceDO::getLocale, reqVO.getLocale())
                .eqIfPresent(UmsResourceDO::getComponentPath, reqVO.getComponentPath())
                .eqIfPresent(UmsResourceDO::getRequiresAuth, reqVO.getRequiresAuth())
                .eqIfPresent(UmsResourceDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(UmsResourceDO::getId));
    }

}
